/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.arqSw.videoMinuto.DAO;
import org.apache.log4j.Logger;
import co.edu.uniminuto.arqSw.videoMinuto.Hibernate.Usuario;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Transaction;

/**
 *
 * @author Administrador
 */
public class SecurityDAO extends GenericDAO{
    
    private static final Logger logger = Logger.getLogger( SecurityDAO.class.getName() );
    
    

    public SecurityDAO(){
        super();
    }
    
    
    public boolean validarUsuario(String login, String passwd){
    
        try{
            Transaction tx = this.getSession().beginTransaction();
            Query q= this.getSession().createQuery("FROM Usuario u WHERE u.login = :login AND u.pass = :passwd");
            q.setParameter("passwd", passwd);
            q.setParameter("login", login);
            
            List<Usuario>  users=(List<Usuario>) q.list();
            if(users.size()>0)
                return true;
            else
                return false;
            

       }catch(Exception e){
            
            e.printStackTrace();
       }
        
    return true;
    
    
    }
}
